//
//  FiltrateBaseTableViewCell.m
//  pmm
//
//  Created by WTFSSD on 2017/7/28.
//  Copyright © 2017年 WTFSSD. All rights reserved.
//

#import "FiltrateBaseTableViewCell.h"


@interface FiltrateBaseTableViewCell()
@property(nonatomic,strong,readwrite)UIView * titleView;
@property(nonatomic,strong,readwrite)UILabel * titleLabel;

@end

@implementation FiltrateBaseTableViewCell


//-(void)awakeFromNib{
//    [super awakeFromNib];
//    [self initSubViews];
//}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
       
        [self initSubViews];
    }
    return self;
}

-(void)initSubViews{

    self.selectionStyle = UITableViewCellSelectionStyleNone;

    UIView * titleView = [[UIView alloc] initWithFrame:CGRectZero];

    [self.contentView addSubview:titleView];
    self.titleView = titleView;
    

    UILabel *titleLabel = [HMLabel createLabelWithText:@"" andTextColor:[UIColor blackColor] andBgColor:[UIColor whiteColor] andFont:[UIFont fontWithName:default_fontname size:autoScaleW(16)] andTextAlignment:NSTextAlignmentLeft];

    [self.titleView addSubview:titleLabel];
    self.titleLabel = titleLabel;
    
    [titleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self.contentView.mas_width);
        make.height.mas_equalTo(autoScaleH(40));
        make.left.equalTo(self.contentView.mas_left);
        make.top.equalTo(self.contentView.mas_top);
    }];
    
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(titleView.mas_centerY);
        make.left.equalTo(self.contentView.mas_left).offset(autoScaleW(10));
        make.width.mas_equalTo(autoScaleW(80));
        make.height.mas_equalTo(autoScaleH(22));
    }];
}

-(void)setExtraView:(UIView *)extraView{
    [_extraView removeFromSuperview];
    if (!extraView) {
        return;
    }
    _extraView = extraView;
    [self.titleView addSubview:_extraView];

    [extraView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.titleView.mas_centerY);
        make.left.mas_equalTo(autoScaleW(267));
        make.width.mas_equalTo(extraView.frame.size.width);
        make.height.mas_equalTo(extraView.frame.size.height);
    }];
}


-(void)setTitle:(NSString *)title{
    _title = title;
    self.titleLabel.text = title;
    [self.titleLabel sizeToFit];
}


@end
